<?php 
	global $ubi;	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>TÙM LUM site</title>
	        
		<link href="include/css/style.css" media="screen" rel="stylesheet" type="text/css" />
		<link href="include/css/styles.css" type="text/css" media="all" rel="stylesheet" id="contact-form-7-css" />
	    <link href="include/css/site.css" media="screen" type="text/css" rel="stylesheet" />
		<link href="include/css/style.pikachoose.css" type="text/css" rel="stylesheet" />
		<link href="include/css/jquery.wysiwyg.css" type="text/css" rel="stylesheet" />
		<link href="include/css/jquery-ui.css" type="text/css" rel="stylesheet" />
		
		<script language="javascript" type="text/javascript" src="include/script/jquery-1.4.4.min.js"></script>
		<script language="javascript" type="text/javascript" src="include/script/jquery.pikachoose.js"></script>
		<script language="javascript" type="text/javascript" src="include/script/jquery.wysiwyg.js"></script>
		<script language="javascript" type="text/javascript" src="include/script/ajaxupload.3.5.js" ></script>
		<script language="javascript" type="text/javascript" src="include/script/jquery-ui-1.8.14.custom.min.js"></script>
		<script language="javascript" type="text/javascript" src="include/script/script.js"></script>
		<script language="javascript" type="text/javascript" src="include/script/userScript.js"></script>
		
		<script type="text/javascript" language="javascript">
			$(document).ready(function(){
				$('#randomItemProvider').load('index.php?load&view=randomItemProvider');
				$('#blockSignIn').load('index.php?load&view=blockSignIn&page=viewUser');
				$('#blockSearch').load('index.php?load&view=blockSearch');
				$('#blockMembers').load('index.php?load&view=blockMembers');
				$('#blockNewestPosts').load('index.php?load&view=blockNewestPosts');
				$('#blockFriends').load('index.php?load&view=friends&userid=<?php echo $getVars['userid']?>');
				$('#blockUpdateOfOwner').load('index.php?load&view=updateOwner&userid=<?php echo $getVars['userid']?>');
				$('#blockUpdateFriends').load('index.php?load&view=updateFriends&userid=<?php echo $getVars['userid']?>');
				$('#mainMenu').load('index.php?load&view=menu');

				$('#userBlast').load('index.php?load&view=userBlast&userid=<?php echo $getVars['userid']?>');
				$('#profileInformation').load('index.php?load&view=profileInformation&userid=<?php echo $getVars['userid']?>');
				$('#sendQuickMessage').load('index.php?load&view=sendQuickMessage&userid=<?php echo $getVars['userid'] ?>');
				$('#quickMessages').load('index.php?load&view=quickMessages&userid=<?php echo $getVars['userid']?>');
				$('#userPostProvider').load('index.php?load&view=userProviderPost&userid=<?php echo $getVars['userid']?>');
				$('#userPostItem').load('index.php?load&view=userItemPost&userid=<?php echo $getVars['userid']?>');

				$('#userMessage').hide();
				$('#footer').load('index.php?load&view=footer');
			});			

			$.extend({
				confirmFriend:function(friendId, ele) {
					var url = "index.php?add&type=friend&userid=" + friendId;
					$.post(url, function(data, messId) {
						if (data != '') { 
							alert('Xác nhận kết bạn thành công !!!');
						} else {
							alert('Xác nhận kết bạn không thành công !!! Bạn hãy thử lại !!!');
						}
					});
				},
				
				makeFriend:function(friendId, ele) {
					var url = "index.php?add&type=friend&userid=" + friendId;
					$.post(url, function(data, messId) {
						if (data != '') { 
							alert('Thêm bạn thành công !!!');
							var messEle = $(ele).parents('.mess');
							var id = $(messEle).attr('id');
							var messID = id.substring(4, id.length);
							$.readMessage(messID);	
						} else {
							alert('Thêm bạn không thành công !!! Bạn hãy thử lại !!!');
						}
					});
				},
				
				readMessage:function(id) {
					var url = "index.php?message&type=read"; 
					$.post(url,	{id:id},
						function(data) {						
							$('#mess' + id).addClass('read');					
						}
					);
				},
				
				deleteMessage:function(id) {
					var url = "index.php?message&type=delete";	
					var page = "<?php echo isset($page)?$page:1?>";
					
					if ($('.mess').length == 1) {
						if (page > 0) {
							page = page - 1;
						}				
					}
							
					$.post(url, {id:id},
							function(data) {
								if (data != '') {
									$('#userMessage').load("index.php?message&type=allMessages&page=" + page);
								}
							}
						);
				},

				viewPageProvider : function(page) {
					$('#userPostProvider').load('index.php?load&view=userProviderPost&userid=<?php echo $getVars['userid']?>&page=' + page);
				},

				viewPageItem : function(page) {
					$('#userPostItem').load('index.php?load&view=userItemPost&userid=<?php echo $getVars['userid']?>&page=' + page);
				}
			});
		</script>
	</head>

	<body>
		<div id="corners">			
			<div class="header" id="main-head">
				<div id="hdr-info">
                	<div style="float:left">
                        <img id="logo" src="include/imgs/logo4.png" width="235px" />
                        <p id="desc">Tùm Lum, Tả Pí Lù, chia sẻ tất cả ở đây</p>
                    </div>
                    <div class="nav">
                        <div id="mainMenu"></div>
                        <div style="clear:both"></div>
                    </div>
				</div>              
			</div> <!--end header-->
            
			<div class="polaroids">
            	<div class="marginBoxPicCollection" id="randomItemProvider"></div>
			</div> <!--end polaris-->
            
            <div id="container">
				<div class="left">
					<div class="section" id="content">
						<div id="userBlast"></div>
                       	<div id="profileInformation"></div>
                       	<div id="sendQuickMessage"></div>
                       	    
                       	<?php
                       		if (isset($_SESSION['userid']) && $_SESSION['userid']) { 
                       	?>    
                       	<div style="margin-bottom:10px">
                       		<input type="button" value="Chia sẻ địa điểm" onclick="location.href='index.php?view&type=shareProvider'" />
                       		<input type="button" value="Chia sẻ món ăn" onclick="location.href='index.php?view&type=shareItem'"/>
                       	</div>        
                       	<?php
                       		} 
                       	?>
                       	<div class="post" id="userMessage"></div>        	
                       	<div id="quickMessages"></div>                   		
                       	<div class="post" id="userPostProvider"></div>
                       	<div class="post" id="userPostItem"></div>                       	
                       	<div class="post" id="blockUpdateFriends"></div>                                     
                    </div>  <!--end section -->
            	</div> <!-- end left -->        
                <div class="right">
        			<div class="aside">
                        <ul class="blockRightSide">	
                        	<h2 class="widgettitle">Đăng nhập</h2>
                            <li class="blockRight" id="blockSignIn"></li>
                            
                            <h2 class="widgettitle">Tìm kiếm</h2>
                            <li class="blockRight" id="blockSearch"></li>
                            
                            <h2 class="widgettitle">Thành viên</h2>
                            <li class="blockRight" id="blockMembers"></li>
                            
							<li class="blockRight" id="blockFriends"></li>
							
							<h2 class="widgettitle">Bài đăng mới nhất</h2>                                                                        
                            <li class="blockRight" id="blockNewestPosts"></li>
                            
                            <li class="blockRight" id="blockUpdateOfOwner"></li>                          
                        </ul>
                    </div>        
                </div> <!--end right-->
			</div> <!--end container-->		
            
            <div id="footer" class="footer clearfix"></div>            
		</div>
	</body>
</html>